package main

import (
	"fmt"
	"time"
)

func main() {
	message := make(chan int, 10)
	done := make(chan bool)
	var a interface{}
	defer close(message)

	go func() {
		ticker := time.NewTicker(time.Second * 5)
		for range ticker.C{
			select {
			case a = <-done:
				fmt.Println("child process interrupt")
				fmt.Printf("%v", a)
				return
			default:
					fmt.Printf("send message : %d\n", <- message)
			}
		}
	}()

	for i := 0; i < 10; i++ {
		message <- i
	}
	time.Sleep(time.Second * 60)
	close(done)
	time.Sleep(time.Second * 1)
	fmt.Println("main process exit")
}
